import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    redirect: '/home'
  },{
    path: '/home',
    name: 'home',
    component: () => import('../views/biz/picture.vue')
  },{
    path: '/login',
    name: 'Login',
    component: () => import('../views/main/login.vue')
  },{
    path: '/config',
    name: 'Config',
    component: () => import('../views/sys/config.vue')
  },{
    path: '/user',
    name: 'User',
    component: () => import('../views/sys/user.vue')
  }
]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

router.afterEach((to, from) => {
  // ...
})
export default router
